<template>
  <div class="map-container">
    <div
      :class="{ 'map-left' : true, 'active' : navActive == true }"
      v-show="isShowControls != false"
    >
      <div class="map-nav">地图导航</div>
      <el-tree
        style="margin-top: 10px;"
        ref="tree"
        @check-change="handleTreeCheck"
        :data="treeData"
        show-checkbox
        default-expand-all
        :props="defaultProps"
      ></el-tree>
    </div>
    <l-map
      ref="map"
      class="map-right"
      :zoom="mapBaseConfig.zoom"
      :center="mapBaseConfig.center"
      :minZoom="mapBaseConfig.minZoom"
      :maxZoom="mapBaseConfig.maxZoom"
      :crs="mapBaseConfig.crs"
    >
      <div v-show="isShowControls != false">
        <l-tile-layer v-if="mapMode == 'sl'" :url="mapLayers.cqVec.tileUrl"></l-tile-layer>
        <l-layer-group v-if="mapMode == 'yx'">
          <l-tile-layer :url="mapLayers.cqImg.tileUrl"></l-tile-layer>
          <l-tile-layer :url="mapLayers.cqMark.tileUrl"></l-tile-layer>
        </l-layer-group>
      </div>

      <!-- <l-layer-group v-if="sideBySideUrl.left != null && sideBySideUrl.right != null">
        <l-tile-layer ref="leftLayer" :url="sideBySideUrl.left"></l-tile-layer>
        <l-tile-layer ref="rightLayer" :url="sideBySideUrl.right"></l-tile-layer>
      </l-layer-group>-->

      <l-tile-layer v-for="(value, key, index) in treeCheckedObj" :key="key" :url="value.tileUrl"></l-tile-layer>

      <l-feature-group ref="features">
        <l-popup class="tdMap-popup-box" :options="{  height: 400, minWidth: 500 }">
          <div class="piankuaiBox">
            <div
              class="piankuaihao"
            >{{ baseInfoData!=null&&baseInfoData!=""?baseInfoData.pkh:'假的片块号' }}</div>
            <div class="piankuaiBox_select">
              <div
                @click="changeTab(1)"
                :class="{piankuaiBox_select_item:true,active:tabFlag==1}"
              >基本信息</div>
              <div
                @click="changeTab(2)"
                :class="{piankuaiBox_select_item:true,active:tabFlag==2}"
              >综合监管</div>
              <div
                @click="changeTab(3)"
                :class="{piankuaiBox_select_item:true,active:tabFlag==3}"
              >审查意见</div>
            </div>
            <div class="jibenxinxi" v-show="tabFlag==1">
              <ul v-if="baseInfoData">
                <li>
                  权利人：
                  <span>{{ baseInfoData.qlr }}</span>
                </li>
                <li>
                  红线面积（㎡）：
                  <span>{{ baseInfoData.sshxm }}</span>
                </li>
                <li>
                  占建设用地类百分比：
                  <span :class="{redText:baseInfoData.jxzdm<50}">{{ baseInfoData.jxzdm }}%</span>
                </li>
                <li>
                  建设用地复垦面积：
                  <span>{{ baseInfoData.sshxm }}</span>
                </li>
                <li>
                  宅基地面积：
                  <span>{{ baseInfoData.nczjd }}</span>
                </li>
                <li>
                  宅基地附属用地面积：
                  <span>{{ baseInfoData.zjdfs }}</span>
                </li>
                <li>
                  预计减少建设用地面积：
                  <span>{{ baseInfoData.yjjsj }}</span>
                </li>
                <li>
                  预计增加农用地面积：
                  <span>{{ baseInfoData.yjzjn }}</span>
                </li>
                <li>
                  预计增加耕地面积：
                  <span>{{ baseInfoData.yjzjg }}</span>
                </li>
                <li>
                  预计增加林地面积：
                  <span>{{ baseInfoData.yjzjl }}</span>
                </li>
                <li>
                  预计增加园地面积：
                  <span>{{ baseInfoData.yjzjy }}</span>
                </li>
                <li>
                  预计增加其他农用地面积：
                  <span>{{ baseInfoData.yjzjq }}</span>
                </li>
                <li>
                  权属单位：
                  <span>{{ baseInfoData.qsdw }}</span>
                </li>
                <li>
                  图幅号：
                  <span>{{ baseInfoData.tfh }}</span>
                </li>
                <li>
                  图斑号：
                  <span>{{ baseInfoData.tbh }}</span>
                </li>
                <li>
                  图斑面积（公顷）：
                  <span>{{ baseInfoData.tbdlm }}</span>
                </li>
                <li>
                  小地名：
                  <span>{{ baseInfoData.xdm }}</span>
                </li>
              </ul>
              <div v-else class="no-data">暂无信息</div>
            </div>
            <div class="jibenxinxi" v-show="tabFlag==2">
              <div class="zonghexinxiFirst zonghexinxiItem">
                <div class="zonghexinxiLeft">现场勘探</div>
                <div class="item-box" v-if="jgInfoData.xctk">
                  <div
                    class="one-item one-item-item item-box-firstItem"
                  >踏勘时间：{{ jgInfoData.xctk.time }}</div>
                  <div class="item-box-box one-item-item">
                    <div class="item-box-box-left">踏勘位置：</div>
                    <div class="item-box-box-right">
                      <div class="one-item check">
                        <el-checkbox
                        disabled
                          :value="false"
                        >是否符合土地利用规划？</el-checkbox>
                      </div>
                      <div class="one-item check">
                        <el-checkbox
                          :value="jgInfoData.xctk.zzgh == 'YES' ? true : false"
                        >是否符合土地整治规划？</el-checkbox>
                      </div>
                      <div class="one-item check">
                        <el-checkbox
                          :value="jgInfoData.xctk.xzjsgh == 'YES' ? true : false"
                        >是否符合乡镇建设规划？</el-checkbox>
                      </div>
                      <div class="one-item check">
                        <el-checkbox
                          :value="jgInfoData.xctk.pddy == 'YES' ? true : false"
                        >坡度是否大于25度？</el-checkbox>
                      </div>
                      <div class="one-item check">
                        <el-checkbox
                          :value="jgInfoData.xctk.qlrzysq == 'YES' ? true : false"
                        >土地权利人是否自愿申请？</el-checkbox>
                      </div>
                      <div class="one-item check">
                        <el-checkbox
                          :value="jgInfoData.xctk.zbnyd == 'YES' ? true : false"
                        >是否与周边农用地相连？</el-checkbox>
                      </div>
                    </div>
                  </div>
                  <div class="table-box">
                    <div class="table-box-left table-box-item">踏勘指界资料</div>
                    <div class="table-box-right table-box-item">
                      <ul class="ziliaoList">
                        <li
                          @click="handleImageDialog(item.src)"
                          v-for="(item,index) in jgInfoData.xctkList"
                          :key="index"
                        >{{item.name}}</li>
                      </ul>
                    </div>
                    <!-- <el-card header="踏勘指界资料" shadow="never">
                      <el-table :header-cell-style="{ background: '#f9f9f9', color: '#606266' }" :data="jgInfoData.xctkList" fit highlight-current-row>
                        <el-table-column type="index" label="序号"></el-table-column>
                        <el-table-column label="文件名称">
                          <template slot-scope="scope">{{ scope.row.name }}</template>
                        </el-table-column>
                        <el-table-column label="操作">
                          <template slot-scope="scope">
                            <el-button size="mini" type="primary" @click="handleImageDialog(scope.row.src)">查看</el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                    </el-card>-->
                  </div>
                </div>
                <div v-else class="no-data">暂无信息</div>
              </div>
              <div class="zonghexinxiFirst zonghexinxiItem">
                <div class="zonghexinxiLeft">前期测绘</div>
                <div class="item-box" v-if="jgInfoData.qqch">
                  <div
                    class="one-item one-item-item item-box-firstItem"
                  >前期测绘：{{ jgInfoData.qqch.time }}</div>
                  <div class="item-box-box one-item-item">
                    <div class="item-box-box-left">测绘位置：</div>
                  </div>
                  <div class="table-box">
                    <div class="table-box-left table-box-item">踏勘指界资料</div>
                    <div class="table-box-right table-box-item">
                      <ul class="ziliaoList">
                        <li
                          @click="handleImageDialog(item.src)"
                          v-for="(item,index) in jgInfoData.qqchList"
                          :key="index"
                        >{{item.name}}</li>
                      </ul>
                    </div>
                  </div>
                </div>
                <div v-else class="no-data">暂无信息</div>
              </div>
            </div>
          </div>
          <div class="jibenxinxi" v-show="tabFlag==3">
            <div class="yijianBox jibenxinxiyijian">
              <div class="yijianBox-item">
                <div class="yijianBox-item-left">该片块图件是否为遗漏复垦点？</div>
                <div class="yijianBox-item-left">
                  <el-radio v-model="isMissingReclaimPoint" label="YES">是</el-radio>
                  <el-radio v-model="isMissingReclaimPoint" label="NO">否</el-radio>
                </div>
              </div>
              <div class="yijianBox-item">
                <div class="yijianBox-item-left">审定规模与送审规模是否一致？</div>
                <div class="yijianBox-item-left">
                  <el-radio @change="isShowThreeInput" v-model="isIdenticalScale" label="YES">是</el-radio>
                  <el-radio @change="isShowThreeInput" v-model="isIdenticalScale" label="NO">否</el-radio>
                </div>
              </div>
            </div>
            <div class="submityijian jibenxinxiyijian">
              <el-button type="primary">提交</el-button>
              <el-button>取消</el-button>
            </div>
          </div>
          <!-- <el-tabs v-model="popupActiveName" class="popup-tab">
            <el-tab-pane label="基本信息" name="baseInfo">
              <ul v-if="baseInfoData">
                <li>片块号：{{ baseInfoData.pkh }}</li>
                <li>权利人：{{ baseInfoData.qlr }}</li>
                <li>红线面积（㎡）：{{ baseInfoData.sshxm }}</li>
                <li>占建设用地类百分比：{{ baseInfoData.jxzdm }}%</li>
                <li>建设用地复垦面积：{{ baseInfoData.sshxm }}</li>
                <li>宅基地面积：{{ baseInfoData.nczjd }}</li>
                <li>宅基地附属用地面积：{{ baseInfoData.zjdfs }}</li>
                <li>预计减少建设用地面积：{{ baseInfoData.yjjsj }}</li>
                <li>预计增加农用地面积：{{ baseInfoData.yjzjn }}</li>
                <li>预计增加耕地面积：{{ baseInfoData.yjzjg }}</li>
                <li>预计增加林地面积：{{ baseInfoData.yjzjl }}</li>
                <li>预计增加园地面积：{{ baseInfoData.yjzjy }}</li>
                <li>预计增加其他农用地面积：{{ baseInfoData.yjzjq }}</li>
                <li>权属单位：{{ baseInfoData.qsdw }}</li>
                <li>图幅号：{{ baseInfoData.tfh }}</li>
                <li>图斑号：{{ baseInfoData.tbh }}</li>
                <li>图斑面积（公顷）：{{ baseInfoData.tbdlm }}</li>
                <li>小地名：{{ baseInfoData.xdm }}</li>
              </ul>
              <div v-else class="no-data">暂无信息</div>
            </el-tab-pane>
            <el-tab-pane label="监管信息" name="jgInfo">
              <el-tabs v-model="jgInfoTabActiveName" type="border-card" class="popup-jg-tab">
                <el-tab-pane v-loading="jgInfoLoading" label="现场踏勘" name="xctk">
                  <div class="item-box" v-if="jgInfoData.xctk">
                    <div class="one-item">踏勘时间：{{ jgInfoData.xctk.time }}</div>
                    <div class="one-item">踏勘位置：{{ jgInfoData.xctk.place }}</div>
                    <div class="one-item check">
                      <el-checkbox :value="jgInfoData.xctk.lygh == 'YES' ? true : false">是否符合土地利用规划？</el-checkbox>
                    </div>
                    <div class="one-item check">
                      <el-checkbox :value="jgInfoData.xctk.zzgh == 'YES' ? true : false">是否符合土地整治规划？</el-checkbox>
                    </div>
                    <div class="one-item check">
                      <el-checkbox :value="jgInfoData.xctk.xzjsgh == 'YES' ? true : false">是否符合乡镇建设规划？</el-checkbox>
                    </div>
                    <div class="one-item check">
                      <el-checkbox :value="jgInfoData.xctk.pddy == 'YES' ? true : false">坡度是否大于25度？</el-checkbox>
                    </div>
                    <div class="one-item check">
                      <el-checkbox :value="jgInfoData.xctk.qlrzysq == 'YES' ? true : false">土地权利人是否自愿申请？</el-checkbox>
                    </div>
                    <div class="one-item check">
                      <el-checkbox :value="jgInfoData.xctk.zbnyd == 'YES' ? true : false">是否与周边农用地相连？</el-checkbox>
                    </div>
                    <div class="table-box">
                      <el-card header="踏勘指界资料" shadow="never">
                        <el-table :header-cell-style="{ background: '#f9f9f9', color: '#606266' }" :data="jgInfoData.xctkList" fit highlight-current-row>
                          <el-table-column type="index" label="序号"></el-table-column>
                          <el-table-column label="文件名称">
                            <template slot-scope="scope">{{ scope.row.name }}</template>
                          </el-table-column>
                          <el-table-column label="操作">
                            <template slot-scope="scope">
                              <el-button size="mini" type="primary" @click="handleImageDialog(scope.row.src)">查看</el-button>
                            </template>
                          </el-table-column>
                        </el-table>
                      </el-card>
                    </div>
                  </div>
                  <div v-else class="no-data">暂无信息</div>
                </el-tab-pane>
                <el-tab-pane v-loading="jgInfoLoading" label="前期测绘" name="qqch">
                  <div class="item-box" v-if="jgInfoData.qqch">
                    <div class="one-item">踏勘时间：{{ jgInfoData.qqch.time }}</div>
                    <div class="table-box">
                      <el-card header="前期测绘现场位置信息" shadow="never">
                        <el-table :header-cell-style="{ background: '#f9f9f9', color: '#606266' }" :data="jgInfoData.qqchList" fit highlight-current-row>
                          <el-table-column type="index" label="序号"></el-table-column>
                          <el-table-column label="文件名称">
                            <template slot-scope="scope">{{ scope.row.name }}</template>
                          </el-table-column>
                          <el-table-column label="操作">
                            <template slot-scope="scope">
                              <el-button size="mini" type="primary" @click="handleImageDialog(scope.row.src)">查看</el-button>
                            </template>
                          </el-table-column>
                        </el-table>
                      </el-card>
                    </div>
                  </div>
                  <div v-else class="no-data">暂无信息</div>
                </el-tab-pane>
              </el-tabs>
            </el-tab-pane>
          </el-tabs>-->
        </l-popup>
      </l-feature-group>

      <!-- <l-marker v-if="markerLatLng != null" :lat-lng="markerLatLng" ></l-marker> -->

      <l-geo-json
        @click="handleClickPolygon($event, item, index)"
        ref="geoJson"
        :optionsStyle="polygonStyleMap.defaultStyle"
        v-for="(item, index) in pkList"
        :key="index"
        :geojson="item.feature"
      ></l-geo-json>

      <!-- 地图模式切换 s -->
      <div v-show="isShowControls != false" class="map-mode">
        <div @click.stop="changeMapMode('sl')" class="map-mode-item sl">
          <div class="text">矢量</div>
        </div>
        <div @click.stop="changeMapMode('yx')" class="map-mode-item yx">
          <div class="text">影像</div>
        </div>
      </div>
      <!-- 地图模式切换 e -->

      <!-- 地图导航收缩开关 s -->
      <div
        v-show="isShowControls != false"
        @click.stop="changeNavActive"
        :class="{ 'nav-switch' : true, 'active' : navActive == true }"
        :title="navActive == true ? '收缩地图导航' : '展开地图导航'"
      >
        <i :class="navActive == true ? 'el-icon-arrow-left' : 'el-icon-arrow-right'"></i>
      </div>
      <!-- 地图导航收缩开关 e -->

      <!-- 地图工具栏 s -->
      <div v-show="isShowControls != false" class="map-tools">
        <div @click="openSideBySidePopup" class="map-tools-item" title="卷帘对比">
          <i class="el-icon-alicompare"></i>
        </div>
        <div id="browserPrint" class="map-tools-item" title="打印">
          <i class="el-icon-aliprint"></i>
        </div>
        <div id="lineMeasure" class="map-tools-item" title="测距">
          <i class="el-icon-aliruler"></i>
        </div>
        <div id="areaMeasure" class="map-tools-item" title="面积测量">
          <i class="el-icon-aliRuler"></i>
        </div>
        <div @click.stop="handleClear" class="map-tools-item" title="清除">
          <i style="font-size: 14px" class="el-icon-aliweibiao45133"></i>
        </div>
        <div
          @click.stop="handleFullScreen"
          class="map-tools-item"
          :title="isFullScreen == true ? '退出全屏' : '全屏'"
        >
          <i
            :class="isFullScreen == true ? 'el-icon-alituichuzhuanhuan' : 'el-icon-aliicon_fullscreen'"
          ></i>
        </div>
      </div>
      <!-- 地图工具栏 e -->
    </l-map>

    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" />
    </el-dialog>

    <el-dialog
      class="side-by-side-popup"
      title="选择卷帘对比的图层"
      :close-on-click-modal="false"
      :visible.sync="sideBySidePopup"
    >
      <el-row :gutter="20">
        <el-col :span="12">
          <el-card header="左侧图层">
            <el-tree
              @node-click="handleSideBySideClick($event, 'left')"
              ref="leftTree"
              :data="treeData"
              :expand-on-click-node="false"
              :highlight-current="true"
              default-expand-all
              :props="defaultProps"
            ></el-tree>
          </el-card>
        </el-col>
        <el-col :span="12">
          <el-card header="右侧图层">
            <el-tree
              @node-click="handleSideBySideClick($event, 'right')"
              ref="rightTree"
              :data="treeData"
              :expand-on-click-node="false"
              :highlight-current="true"
              default-expand-all
              :props="defaultProps"
            ></el-tree>
          </el-card>
        </el-col>
      </el-row>
      <el-row>
        <el-button @click="handleSideBySide" class="confirm-btn">确定选择</el-button>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
// var L = require("@/lib/leaflet/leaflet");
import {
  LMap,
  LTileLayer,
  LPopup,
  LLayerGroup,
  LGeoJson,
  LFeatureGroup,
  LControl,
  LMarker
} from "vue2-leaflet";
import "leaflet/dist/leaflet.css";
import "@/icons/iconfont.css";
import "leaflet.browser.print/dist/leaflet.browser.print";

import icon from "leaflet/dist/images/marker-icon.png";
import iconShadow from "leaflet/dist/images/marker-shadow.png";
let DefaultIcon = L.icon({
  iconUrl: icon,
  shadowUrl: iconShadow
});
L.Marker.prototype.options.icon = DefaultIcon;

import "@/lib/leaflet/control.css";
import "@/lib/leaflet/control.js";

import { QScreenSwitcher } from "@/utils/common.js";

var esri = require("esri-leaflet");
import { getXctkDetail, getQqchDetail } from "@/api/tdMap";
import config from "@/config";

export default {
  name: "tdMap",
  components: {
    LMap,
    LTileLayer,
    LPopup,
    LLayerGroup,
    LGeoJson,
    LFeatureGroup,
    LControl,
    LMarker
  },
  props: ["pkList", "isShowControls"],
  data() {
    return {
      //显示四个输入框
      showThreeFlag: false,
      //是否为缺失遗漏点
      isMissingReclaimPoint: "NO",
      //审定规模与送审规模是否一致
      isIdenticalScale: "NO",
      //切换选项卡
      tabFlag: 1,
      // 地图图层模式
      mapMode: "yx", // yx影像；sl矢量
      // 地图弹层
      mapPopup: null,
      // 地图配置
      mapBaseConfig: {
        center: [29.57, 106.55],
        zoom: 10,
        minZoom: 0,
        maxZoom: 17,
        zoomControl: true,
        crs: L.CRS.EPSG4326
      },
      // 地图图层
      mapLayers: {
        // 矢量
        cqVec: esri.tiledMapLayer({
          url:
            "http://www.digitalcq.com/tianditu/hlvdl/765c64c33a9d4beeae5c5329da6caebf"
        }),
        // 影像
        cqImg: esri.tiledMapLayer({
          url:
            "http://www.digitalcq.com/tianditu/kxrgo/ca295a0983c5473a825b1e4700adb81b"
        }),
        // 影像注记
        cqMark: esri.tiledMapLayer({
          url:
            "http://www.digitalcq.com/tianditu/ewfwz/ff74349b1483497d913ec396ee35065b"
        })
      },
      // geoJson style
      polygonStyleMap: {
        defaultStyle: {
          color: "#ff0000",
          weight: 1,
          fillOpacity: 0.2
        },
        activeStyle: {
          color: "#F56C6C",
          weight: 1,
          fillOpacity: 0.2
        }
      },

      // 地图导航配置
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 地图导航数据
      treeData: [
        {
          id: 1,
          label: "土地利用规划",
          disabled: true,
          children: [
            {
              id: 5,
              label: "总体规划",
              disabled: true
            },
            {
              id: 6,
              label: "管理区规划",
              disabled: true
            },
            {
              id: 7,
              label: "土地整治规划",
              disabled: true
            }
          ]
        },
        {
          id: 2,
          label: "土地利用现状",
          children: [
            {
              id: 8,
              label: "2018年",
              url: esri.tiledMapLayer({
                url:
                  "http://222.178.223.250:2136/arcgis/rest/services/tdzz/tdlyxz_3/MapServer"
              })
            },
            {
              id: 9,
              label: "2017年",
              disabled: true
            },
            {
              id: 10,
              label: "2016年",
              disabled: true
            },
            {
              id: 11,
              label: "2015年",
              disabled: true
            }
          ]
        },
        {
          id: 3,
          label: "年度变更影像",
          children: [
            {
              id: 12,
              label: "2018年",
              disabled: true
            },
            {
              id: 13,
              label: "2017年",
              url: esri.tiledMapLayer({
                url:
                  "http://www.digitalcq.com/tianditu/dsrqc/c54e73a8bdd441b495ee531110f8086b"
              })
            },
            {
              id: 14,
              label: "2016年",
              url: esri.tiledMapLayer({
                url:
                  "http://www.digitalcq.com/tianditu/pzosy/a0abcb4bb7db466e973cbd8867b47fe6"
              })
            },
            {
              id: 15,
              label: "2015年",
              url: esri.tiledMapLayer({
                url:
                  "http://www.digitalcq.com/tianditu/hrjvz/6691ab289e6745feaa6580c630afe945"
              })
            }
          ]
        },
        {
          id: 4,
          label: "城市规划",
          disabled: true,
          children: [
            {
              id: 16,
              label: "用地规划",
              disabled: true
            },
            {
              id: 17,
              label: "控规用地规划",
              disabled: true
            },
            {
              id: 18,
              label: "总规深化用地规划",
              disabled: true
            }
          ]
        }
      ],

      // 页面参数
      navActive: true,
      polygonArr: [],
      polygonMap: {},
      geoJsonArr: [],
      geoJsonOptions: {},
      popupActiveName: "baseInfo",
      baseInfoData: null, // 基本信息数据
      jgInfoData: {
        //监管信息数据
        xctk: null, // 现场踏勘
        xctkList: [],
        qqch: null, // 前期测绘
        qqchList: [],
        cgcs: null // 成果初审
      },
      jgInfoTabActiveName: "xctk",
      jgInfoLoading: false,
      dialogVisible: false,
      dialogImageUrl: null,
      treeCheckedObj: {},
      control: {
        lineMeasure: null,
        areaMeasure: null,
        browserPrint: null,
        siderCompare: null
      },
      fullScreen: new QScreenSwitcher(),
      isFullScreen: false,

      isFalse: true,
      sideBySidePopup: false, //卷帘对比选择弹窗
      sideBySideStatus: "close",
      sideBySideUrl: {
        left: null,
        right: null
      },
      markerLatLng: null
    };
  },
  watch: {
    pkList() {
      // 监听片块列表变化
      this.initMap();
    },
    baseInfoData() {
      this.getXctkData();
      this.getQqchData();
    }
    // popupActiveName(val) {
    //   if (val == "jgInfo") {
    //     this.getXctkData();
    //   }
    // },
    // jgInfoTabActiveName(val) {
    //   if (val == "xctk") {
    //     this.getXctkData();
    //   } else if (val == "qqch") {
    //     this.getQqchData();
    //   }
    // }
  },
  methods: {
    //切换单选
    isShowThreeInput(e) {
      if (e == "NO") {
        this.showThreeFlag = true;
      } else {
        this.showThreeFlag = false;
      }
    },
    //切换选项卡
    changeTab(num) {
      this.tabFlag = num;
    },
    handleFullScreen() {
      // 全屏
      if (this.isFullScreen) {
        this.fullScreen.exitFullScreen(this.$refs.map.$el);
      } else {
        this.fullScreen.enterFullScreen(this.$refs.map.$el);
      }
      this.isFullScreen = !this.isFullScreen;
    },
    handleClear() {
      // 清除测距、面积测距
      let _lineMeasureLayer = this.control["lineMeasure"]["_layerPaint"];
      let _areaMeasureLayer = this.control["areaMeasure"]["_layer"];
      if (_areaMeasureLayer != null) {
        for (var k in _areaMeasureLayer["_layers"]) {
          _areaMeasureLayer.removeLayer(_areaMeasureLayer["_layers"][k]);
        }
      }
      if (_lineMeasureLayer != null) {
        _lineMeasureLayer.clearLayers();
      }
    },
    openSideBySidePopup() {
      if (this.sideBySideStatus == "close") {
        this.sideBySidePopup = true;
      } else {
        this.$refs.map.mapObject.removeLayer(this.sideBySideUrl.left);
        this.$refs.map.mapObject.removeLayer(this.sideBySideUrl.right);
        this.control.siderCompare.remove();
        this.sideBySideStatus = "close";
      }
    },
    handleSideBySideClick(e, name) {
      if (e.url) {
        this.sideBySideUrl[name] = e.url;
      } else {
        this.sideBySideUrl[name] = null;
        this.$message({
          message: `${name == "left" ? "左侧" : "右侧"}所选图层暂无数据`,
          type: "warning"
        });
      }
    },
    handleSideBySide() {
      // 卷帘对比
      if (this.sideBySideUrl.left == null) {
        this.$message({
          message: `左侧所选图层暂无数据`,
          type: "warning"
        });
        return;
      }
      if (this.sideBySideUrl.right == null) {
        this.$message({
          message: `右侧所选图层暂无数据`,
          type: "warning"
        });
        return;
      }
      let left = this.sideBySideUrl.left;
      let right = this.sideBySideUrl.right;
      this.$refs.map.mapObject.addLayer(left);
      this.$refs.map.mapObject.addLayer(right);
      this.control.siderCompare = L.control
        .sideBySide(left, right)
        .addTo(this.$refs.map.mapObject);
      this.sideBySidePopup = false;
      this.sideBySideStatus = "open";
    },
    initMap() {
      this.$nextTick(() => {
        let _geoJsonArr = [];
        this.$refs.geoJson.forEach((item, index) => {
          _geoJsonArr.push(item.getBounds());
        });
        this.geoJsonArr = _geoJsonArr;
        this.$refs.map.fitBounds(this.geoJsonArr); // 定位到图形位置

        if (this.isShowControls == false) {
          let arr = this.pkList[0].point.split(" ");
          this.markerLatLng = [arr[1], arr[0]];
          L.marker(this.markerLatLng).addTo(this.$refs.map.mapObject);
        }

        // 加载测距、面积测距、打印控件
        this.control.lineMeasure = L.control
          .lineMeasure({ drawBtn: document.getElementById("lineMeasure") })
          .addTo(this.$refs.map.mapObject);
        this.control.areaMeasure = L.control
          .areaMeasure({ drawBtn: document.getElementById("areaMeasure") })
          .addTo(this.$refs.map.mapObject);
        this.control.browserPrint = L.control
          .browserPrint({ el: document.getElementById("browserPrint") })
          .addTo(this.$refs.map.mapObject);
      });
    },
    changeMapMode(mode) {
      // 切换地图模式
      this.mapMode = mode;
    },
    changeNavActive() {
      // 地图导航开关
      this.navActive = !this.navActive;
      this.$nextTick(() => {
        this.$refs.map.mapObject.invalidateSize(true);
      });
    },
    handleClickPolygon(e, item, index) {
      // 点击多边形开启片块详情popup
      this.baseInfoData = item;
      this.$nextTick(() => {
        this.$refs.features.mapObject.openPopup([e.latlng.lat, e.latlng.lng]);
      });
    },
    changePkPosition(index) {
      // 点击
      this.restorePolygonStyle();
      let currentPolygon = this.$refs.geoJson[index];
      currentPolygon.setOptionsStyle(this.polygonStyleMap.activeStyle);
      this.$refs.map.fitBounds(currentPolygon.getBounds());
    },
    restorePolygonStyle() {
      // 重置地图片块样式
      this.$refs.geoJson.forEach((item, index) => {
        item.setOptionsStyle(this.polygonStyleMap.defaultStyle);
      });
    },
    getXctkData() {
      // 获取现场踏勘数据
      this.jgInfoLoading = true;
      getXctkDetail({
        landId: this.baseInfoData.landId
      })
        .then(res => {
          this.jgInfoLoading = false;
          this.jgInfoData.xctk = res.data;
          this.jgInfoData.xctkList = [
            { name: "情况说明照片1", src: config.baseUrl + res.data.photo1 },
            { name: "情况说明照片2", src: config.baseUrl + res.data.photo1 }
          ];
        })
        .catch(err => {
          this.jgInfoLoading = false;
        });
    },
    getQqchData() {
      // 获取前期测绘数据
      this.jgInfoLoading = true;
      getQqchDetail({
        landId: this.baseInfoData.landId
      })
        .then(res => {
          this.jgInfoLoading = false;
          this.jgInfoData.qqch = res.data;
          this.jgInfoData.qqchList = [
            {
              name: "复垦点方位一照片",
              src: config.baseUrl + res.data.landPositionOneFilePath
            },
            {
              name: "复垦点方位二照片",
              src: config.baseUrl + res.data.landPositionTwoFilePath
            },
            {
              name: "复垦点方位三照片",
              src: config.baseUrl + res.data.landPositionThreeFilePath
            },
            {
              name: "复垦点方位四照片",
              src: config.baseUrl + res.data.landPositionFourFilePath
            },
            {
              name: "空中全景照片",
              src: config.baseUrl + res.data.panoramagramFilePath
            }
          ];
        })
        .catch(err => {
          this.jgInfoLoading = false;
        });
    },
    handleImageDialog(url) {
      this.dialogImageUrl = url;
      this.dialogVisible = true;
    },
    handleTreeCheck(obj, isChecked) {
      if (obj.url) {
        if (isChecked == true) {
          this.treeCheckedObj[obj.id] = obj.url;
        } else {
          delete this.treeCheckedObj[obj.id];
        }
      }
      this.$forceUpdate();
    }
  },
  created() {
    // if (!this.isShowControls) {
    //   this.isShowControls = true;
    // }
  }
};
</script>
<style>
/* .tdMap-popup-box {
  width: 60%;
  height: 460px;
}
.tdMap-popup-box .leaflet-popup-content-wrapper {
  width: 100%;
}

.tdMap-popup-box .leaflet-popup-content {
  width: 100%;
  margin: 0;
  padding: 20px;
  box-sizing: border-box;
} */
</style>
<style lang="scss" scoped>
.map-container {
  display: flex;
  justify-content: center;
  // margin-top: 30px;
  margin-bottom: 30px;
}
.map-left {
  width: 0;
  border: 1px solid #e9e9e9;
  border-right: none;

  &.active {
    width: 230px;
  }
}
.map-nav {
  background: #f2f2f2;
  height: 40px;
  border-bottom: 1px solid #e9e9e9;
  overflow: hidden;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  color: #4d4d4d;
  line-height: 40px;
}
.map-right {
  position: relative;
  width: 100%;
  height: 600px;
}
.map-mode {
  display: flex;
  flex-direction: row;
  width: auto;
  height: 62px;
  overflow: hidden;
  font-size: 0;
  position: absolute;
  z-index: 1001;
  right: 0;
  bottom: 30px;

  &-item {
    position: relative;
    width: 62px;
    height: 62px;
    display: block;
    overflow: hidden;
    border: 1px solid #308be7;
    margin-right: 10px;
    cursor: pointer;

    .text {
      background: rgba(0, 0, 0, 0.5);
      width: 100%;
      height: 20px;
      display: block;
      overflow: hidden;
      font-size: 13px;
      color: #fff;
      text-align: center;
      line-height: 20px;
      position: absolute;
      left: 0;
      bottom: 0;
      z-index: 1;
    }
  }

  &-item.yx {
    background: url("../../assets/map/type-img-icon.png");
    background-repeat: no-repeat;
    background-size: cover;
  }

  &-item.sl {
    background: url("../../assets/map/type-vector-icon.png");
    background-repeat: no-repeat;
    background-size: cover;
  }
}

.nav-switch {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  background: #fff;
  width: 20px;
  height: 30px;
  border: 1px solid #ccc;
  border-left: 0 none;
  display: block;
  overflow: hidden;
  font-size: 18px;
  text-align: center;
  line-height: 30px;
  position: absolute;
  z-index: 1001;
  border-radius: 0 5px 5px 0;
  cursor: pointer;
}

.popup-tab {
  position: relative;

  ul {
    margin: 0;
    padding: 0;
    list-style: none;
    height: 330px;
    overflow-y: auto;
  }

  li {
    font-size: 14px;
    color: #444;
    min-height: 30px;
    padding: 10px 10px;
  }

  .no-data {
    width: 100%;
    overflow: hidden;
    color: #444;
    font-size: 16px;
    font-weight: bold;
    line-height: 1.5;
    padding: 0 10px;
    text-align: center;
    margin: 35px 0;
    clear: both;
  }
}

.popup-jg-tab {
  height: 330px;
  overflow-y: auto;

  .one-item {
    height: 30px;
    overflow: hidden;
    font-size: 13px;
    color: #999;
    line-height: 30px;
  }

  .one-item.check /deep/ .el-checkbox__input.is-checked + .el-checkbox__label {
    font-size: 14px;
    color: #12203e;
  }

  .table-box {
    margin-top: 10px;
  }
}
.one-item.check {
  margin-bottom: 10px;
}
.popup-jg-tab /deep/ .el-card__body {
  padding: 0;
}

.map-tools {
  width: auto;
  height: 30px;
  border-radius: 5px;
  box-shadow: 1px 1px 2px #666;
  overflow: hidden;
  font-size: 0;
  position: absolute;
  z-index: 1001;
  right: 10px;
  top: 10px;
  cursor: pointer;

  &-item {
    background: #fff;
    height: 30px;
    padding: 0 10px;
    border-right: 1px solid #efefef;
    display: inline-block;
    overflow: hidden;
    line-height: 30px;
    font-size: 0;
    color: #666;

    i {
      color: #666;
      vertical-align: middle;
    }

    &:hover {
      background: #efefef;
    }
  }
}

.leaflet-control-browser-print {
  display: none;
}

.side-by-side-popup {
  text-align: center;

  .confirm-btn {
    margin-top: 26px;
  }

  /deep/
    .el-tree--highlight-current
    .el-tree-node.is-current
    > .el-tree-node__content {
    // background-color: #f9b5a3;
    background-color: rgb(160, 207, 255);
  }
}

.piankuaiBox_select {
  display: flex;
  margin-top: 29px;
  margin-left: 21px;
  .piankuaiBox_select_item {
    width: 88px;
    height: 36px;
    background: #fff;
    opacity: 1;
    border-radius: 2px;
    color: #999999;
    text-align: center;
    line-height: 36px;
    font-size: 14px;
    margin-right: 8px;
    cursor: pointer;
  }
  .piankuaiBox_select_item.active {
    background: rgba(238, 243, 248, 1);
    color: #1d88f3;
  }
}
.piankuaihao {
  font-size: 20px;
  line-height: 28px;
  padding: 10px 0 21px 0;
  color: #333333;
  margin-left: 21px;
  border-bottom: 1px solid #f2f2f2;
}
.jibenxinxi {
  padding-bottom: 60px;
  height: 300px;
  overflow-x: hidden;
  overflow-y: auto;
  ul {
    list-style: none;
    overflow: hidden;
    padding-left: 10px;
    margin-top: 30px;
    li {
      float: left;
      color: #b3b3b3;
      font-size: 13px;
      margin-right: 40px;
      margin-bottom: 16px;
      span {
        color: #666666;
      }
      .redText {
        color: red;
      }
    }
  }
}
.zonghexinxiFirst {
  display: flex;
  margin-top: 30px;
  .zonghexinxiLeft {
    width: 88px;
    font-size: 14px;
    color: #333333;
  }
}
.zonghexinxiItem {
  margin-left: 20px;
}
.item-box-box {
  display: flex;
  .item-box-box-left {
    width: 82px;
    font-size: 13px;
    color: #b3b3b3;
  }
}
.one-item-item {
  margin-bottom: 21px;
}
.item-box-firstItem {
  font-size: 13px;
  color: #b3b3b3;
}
.table-box {
  overflow: hidden;
  .table-box-item {
    float: left;
    margin-right: 10px;
    margin-bottom: 10px;
  }
}
.table-box-left {
  font-size: 13px;
  color: #b3b3b3;
}
.jibenxinxi .ziliaoList {
  overflow: hidden;
  margin-top: 0;
  padding-left: 0;
  li {
    float: left;
    font-size: 13px;
    color: #1d88f3;
    margin-left: 18px;
    margin-right: 0;
    cursor: pointer;
  }
}
.yijianBox-item {
  margin-bottom: 20px;
  font-size: 14px;
  color: #666666;
  display: flex;
  .yijianBox-item-left {
    margin-right: 30px;
  }
}
.jibenxinxiyijian {
  margin-top: 33px;
  margin-left: 10px;
}
.submityijian {
  margin-top: 60px;
}
</style>
